/* ============ 遮罩 ============ */

.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-mask.modal-mask-animate {
    animation: maskFadeIn 0.3s ease forwards;
}

.modal-mask.modal-mask-show {
    opacity: 1;
}

@keyframes maskFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============ 弹窗容器 ============ */

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    min-width: 300px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: all 0.3s ease;
}

.modal.modal-animate {
    animation: modalPopIn 0.3s ease forwards;
}

.modal.modal-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ============ 弹窗头部 ============ */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

/* ============ 弹窗内容 ============ */

.modal-body {
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============ 弹窗底部 ============ */

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

.modal-footer .btn {
    padding: 8px 20px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.modal-footer .btn-primary {
    background: var(--primary-color);
    color: white;
}

.modal-footer .btn-primary:hover {
    opacity: 0.9;
}

.modal-footer .btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.modal-footer .btn-secondary:hover {
    background: var(--border-color);
}

/* ============ 弹窗类型样式 ============ */

.modal-alert .modal-header {
    border-bottom-color: #1890ff;
}

.modal-confirm .modal-header {
    border-bottom-color: #faad14;
}

.modal-success .modal-header {
    border-bottom-color: #52c41a;
}

.modal-success .modal-title::before {
    content: '✓ ';
    color: #52c41a;
    font-weight: bold;
}

.modal-error .modal-header {
    border-bottom-color: #ff4d4f;
}

.modal-error .modal-title::before {
    content: '✕ ';
    color: #ff4d4f;
    font-weight: bold;
}

/* ============ 响应式 ============ */

@media (max-width: 768px) {
    .modal {
        width: 90vw;
        max-width: 90vw;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .modal {
        width: 95vw;
        max-width: 95vw;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-body {
        padding: 12px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-close {
        font-size: 24px;
    }
}
